package com.bailun91.auth.mapper;


import com.bailun91.auth.entity.Permission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PermissionMapper extends BaseMapper<Permission> {

    /**
     * 查询某个角色对应的权限
     *
     * @param roleId
     * @return
     */
    @Select("SELECT p.* FROM c_role_permission rp\n" +
            "LEFT JOIN c_permission p ON (p.permission_id = rp.permission_id)\n" +
            "WHERE rp.role_id = #{role_id};")
    List<Permission> findPermissionListByRoleId(@Param("role_id") int roleId);


    @Select("SELECT * FROM c_permission")
    List<Permission> findAllPermissions();

}
